package com.qys.livesMall.open.controller.app;

import com.qys.livesMall.common.result.R;
import com.qys.livesMall.framework.utils.SecurityUtils;
import com.qys.livesMall.open.modal.dto.app.H2AppOpenPushDTO;
import com.qys.livesMall.open.modal.entity.H2AppOpenPush;
import com.qys.livesMall.open.modal.vo.H2AppOpenPushVo;
import com.qys.livesMall.open.service.H2AppOpenPushService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 
 * @since 2023-07-20
 */
@RestController
@Tag(name = "用户推送权限")
@RequestMapping("/app/appOpenPush")
@RequiredArgsConstructor
@Slf4j
public class H2AppOpenPushController {

    private final H2AppOpenPushService h2AppOpenPushService;

    @GetMapping("/info")
    @Operation(summary = "获取用户推送权限")
    public R<List<H2AppOpenPushVo>> getinfo(){
        return R.ok(h2AppOpenPushService.getinfo(SecurityUtils.getUserId()));
    }

    @PostMapping("/adds")
    @Operation(summary = "保存用户推送权限")
    public R<?> adds(@RequestBody @Validated List<H2AppOpenPushDTO> list){
        return R.ok(h2AppOpenPushService.adds(list));
    }
}
